-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Add public API function pytest.match_markexpr for marker expression e… #13783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add public API function pytest.match_markexpr for marker expression e… #13783
Conversation
705cd94
to
b7f2edb
Compare
…valuation - Introduced match_markexpr to match marker expressions against markers or pytest Items. - Updated documentation to reflect the new function. - Added comprehensive tests to ensure functionality and error handling. Closes pytest-dev#13737
b7f2edb
to
f87cc2b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I won't get to do a deep review this weekend however direct concenience for only exactly your usecase is not the api we should expose
The costs there are all wrong for anything but single use
Its not appropriate for something like usage in modifyitems
Thanks for having a look at this so quickly. could you clarify a few things for me so I can get to work in the right direction.
if I understand you correctly, your concern is that if the code was used in this state in modifyitems? the result would not be optimal? |
a key use case for the matching is something like pytest/src/_pytest/mark/__init__.py Lines 256 to 271 in 09a9c6a
which requires a loop over all items with the matcher exposing the functionality as one off one by one will sabotage users from using it like that we have to have a discussion about a good api to expose that includes parsing and preparing match dicts |
@nicoddemus @bluetech some input needed i was thinking we might want to expose Expression under the name MarkExpression and then expand it with additionally i'd recommend to add the _pytest_private hack to its ctor and keep the input sequence around for the repr/debugging |
Not exposed to exposing I don't think the name
I wouldn't want to do this, currently |
The idea for the exposed api includes some considerations for convenience as for general consumption the additional exposure of the matchers for marks/keyeords and their consequent usage seems cumbersome If its for internal usage the separation is great as thr usage points are limited But the developer experience for that api is a bit cumbersome |
@RonnyPfannschmidt and that would make, the general goal an API which allows the user to complie and evaluate expressions. That all being true than the idea of exposing the class The risks being as I see it that this is an integral part of the project which we are now exposing which could causes issues in future if we want to refactor or change it significantly. |
I believe you overestimate the impact of providing expression Yes it will require some care however it's not deeply embedded |
@RonnyPfannschmidt ok, thanks for clarifying. |
@RonnyPfannschmidt I guess that all comes down to the expected usage of such APIs?. in my mind it makes sense someone would want to check if a mark they passed in -m is going to collect all the tests they expect it to collect and maybe fail if not so they don't run their whole CI while missing critical tests. |
Please show where your usecase would happen |
@RonnyPfannschmidt not sure what you mean but if I understand you correctly, you're asking for an example of where the use case I am suggesting would happen. i was speaking in general about possible use cases for this public API since I don't have any actual use cases apart from the one the initial requester for of this API mentioned, so I was theorizing a use case. |
Added a public function which evaluates markers matching
close: #13759